1. These are the three main parts of error handlers in Visual Basic:
· The On Error Goto statement
· The error handler code
· The Exit statement
2. The four ways to exit an error handler routine are
·Resume: Returns to execute the code that caused the error.
·Resume Next: Resumes execution of the Visual Basic code at the line immediately following the line that created the error.
·Resume label: Resumes execution at a specified location in the program that caused the error.
·EXIT SUB or EXIT function: Exits the routine in which the error occurred. You could also use END to exit the program completely.
3. You use Resume to exit an error handler when users have done something that they can easily correct. For example, a user may have forgotten to insert a disk in drive A or close the drive door.
4. You would use Resume Next to exit an error handler when the program runs properly even though an error has been reported, or if code within the program corrects the problem.
5. You use Resume label to exit an error handler when you want the program to return to a portion of code that allows for correction of the invalid entry. For example, if the user enters numeric data that yields improper results (division by zero, for example) you may want the code to redisplay the input screen so that entry can be corrected.
6. You would use the EXIT command or the END command to terminate the program when there is no good way to return to the program once the error has occurred. This might happen if the user forgot to log onto a network or if there is insufficient memory to run the program.
7. The following are the four types of Visual Basic errors:
· General file errors: Errors that occur when you try to open, read, or write file information.
· Database errors: Errors that occur during database operations such as reads, writes, or data object creation or deletion.